﻿using System;
using System.ComponentModel;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace BusinessLogic
{
    public class RM
    {
        public static void RoomManagementOfQuery(DataGridView dgv,string methods,string input)
        {
            DataSet ds = DataAccess.RM.RoomManagementOfQuery(methods,input);
            dgv.DataSource = ds.Tables[0].DefaultView;
        }

        public static int AddRoom(string roomID,string roomType,string roomPrice)
        {
            if(DataAccess.RM.IsRoomExist(roomID))
            {
                MessageBox.Show("Room already exists!");
                return 0;
            }
            DataAccess.RM _rm = new DataAccess.RM();
            _rm.roomID = roomID;
            _rm.roomType = roomType;
            _rm.roomPrice = Convert.ToDouble(roomPrice);

            int result = DataAccess.RM.AddRoom(_rm);
            return result;
        }


        public static int DeleteRoom(string roomID)
        {
            DataAccess.RM _rm = new DataAccess.RM();
            _rm.roomID = roomID;
            int result = DataAccess.RM.DeleteRoom(_rm);
            return result;
        }
        public static int DeleteRoomStatus(string roomID)
        {
            DataAccess.RM _rm = new DataAccess.RM();
            _rm.roomID = roomID;
            int result = DataAccess.RM.DeleteRoomStatus(_rm);
            return result;
        }

        public static int ModifyRoom(string roomID,string roomType,string roomPrice)
        {
            DataAccess.RM _rm = new DataAccess.RM();
            _rm.roomID = roomID;
            _rm.roomType = roomType;
            _rm.roomPrice = Convert.ToDouble(roomPrice);

            int result = DataAccess.RM.ModifyRoom(_rm);
            return result;

        }
        public static object dgv()
        {
            object ds = DataAccess.RM.dgv();
            return ds;
        }
        public static int updateroom()
        {
            int result = DataAccess.RM.updateroom();
            return result;
        }
        public static int AddintoRs(string roomID, string roomType, string roomPrice,string roomStatus)
        {
             
            DataAccess.RM _rs = new DataAccess.RM();
            _rs.roomID = roomID;
            _rs.roomType = roomType;
            _rs.roomPrice = Convert.ToDouble(roomPrice);
            _rs.roomStatus = roomStatus;
            int result = DataAccess.RM.AddintoRs(_rs);
            return result;
        }
    }
}
